package com.flexdms.i18n.test.func;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;

import org.codehaus.plexus.compiler.javac.JavaxToolsCompiler;

import com.flexdms.i18n.FacesMessage;

@RequestScoped
@Named("fm")
public class FacesMessageer implements Serializable
{
	int value=5;
		
	public int getValue()
	{
		return value;
	}

	public void setValue(int value)
	{
		this.value = value;
	}

	@PostConstruct
	public void init()
	{
		FacesContext ctx=FacesContext.getCurrentInstance();
		
		FacesMessage msg1=new FacesMessage(FacesMessage.SEVERITY_ERROR, "Not localized", null);
		msg1.setShouldTranslate(false);
		ctx.addMessage("f:i1", msg1);
		
		msg1=new FacesMessage(FacesMessage.SEVERITY_ERROR, "Something Wrong", null);
		ctx.addMessage("f:i2", msg1);
		
		msg1=new FacesMessage(FacesMessage.SEVERITY_ERROR, "My Name is {0}", null) ;
		Object params[]= {"Jason"};
		msg1.setParams(params);
		ctx.addMessage("f:i3", msg1);
		
		javax.faces.application.FacesMessage msg2=new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, "Something Wrong", null);
		ctx.addMessage("f:i4", msg2);
	}
}
